// 获取地址栏参数信息
function _getQueryId(name){
    const reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', "i");
    const r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]);
    return '';
};
function getParames(name) {
    var after = window.location.hash.split("?")[1];
    if(after){
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        var r = after.match(reg);
        if (r != null) return decodeURIComponent(r[2]);
        return null;
    }
}

// 判断是ios还是android
function getDevice() {
    const u = navigator.userAgent;
    const isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
    const isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
    
    if (isAndroid)
        return 'android';
    if (isiOS)
        return 'ios';
    return 'android';
}


function rangeMatch_noun(){
    var now = new Date(); //当前日期
    var nowDayOfWeek = now.getDay(); //今天本周的第几天
    var nowDay = now.getDate(); //当前日
    var nowMonth = now.getMonth(); //当前月
    var nowYear = now.getFullYear(); //当前年

    var weekStartDate = new Date(nowYear, nowMonth, (nowDay - nowDayOfWeek+1));
    var weekEndDate = new Date(nowYear, nowMonth, nowDay + (6 - nowDayOfWeek+1));

    var monthStartDate = new Date(nowYear, nowMonth, 1);
    var monthEndDate = new Date(nowYear, nowMonth + 1, 1);
    var days = (monthEndDate - monthStartDate) / (1000 * 60 * 60 * 24);
    monthEndDate = new Date(nowYear, nowMonth, days);

    return {
        weekStart : formatDate(weekStartDate),
        weekEnd : formatDate(weekEndDate),
        monthStart : formatDate(monthStartDate),
        monthEnd : formatDate(monthEndDate)
    }
} 

function formatDate(date) {
    var myyear = date.getFullYear();
    var mymonth = date.getMonth() + 1;
    var myweekday = date.getDate();
    if (mymonth < 10) {
        mymonth = "0" + mymonth;
    }
    if (myweekday < 10) {
        myweekday = "0" + myweekday;
    }
    return (myyear + "-" + mymonth + "-" + myweekday);
}